<?php

class ProductController extends Zend_Controller_Action
{
 
  public function reviewproductAction()
    {
		$id = (int)$this->getRequest()->getParam('p_id');
	    $reviewsFinder = new Model_ProductDetails();
		$reviews = $reviewsFinder->getProductDetails($id);
		$viewdes = array();
		$array = array();
		$i=0;
		foreach( $reviews as $x)
		{
		 $modelCatdes = new Model_Catdes();
		 $array = $modelCatdes->getCatdesDetail($x['catdes_id']);
		 //echo " Array hien thoi la: <br />" . var_dump($array);
		 $viewdes[$i]['catdes_ten']=  $array[0]['catdes_ten'];
		 $viewdes[$i]['pdetail_mota']=  $x['pdetail_mota'];
		 $i++;
		}
		$this->view->viewdes=$viewdes;
		//lay link anh
		$modelProduct=new Model_Product();
		$pviews= $modelProduct->getProductById($id);
		$this->view->pimg=$pviews[0]['p_linkImg'];
		$this->view->pten=$pviews[0]['p_ten'];
		$this->view->pgia=$pviews[0]['p_gia'];
		$this->view->pid=$pview[0]['p_id'];
		 
		$modelCateProduct= new Model_Product();
		$productbyCategory=$modelCateProduct->getProductCategoryexPid($pviews[0]['cat_id'],$id);
		
		/*$pageNumber = 4 ; //or whatever you wish
		$itemNumber = 3; //or whatever you wish
		$paginator = Zend_Paginator::factory($productbyCategory);
		
		$paginator->setItemCountPerPage($itemNumber);
		$paginator->getItemsByPage($pageNumber);
		$paginator->setCurrentPageNumber($this->_getParam('page'));
		Zend_Paginator::setDefaultScrollingStyle('Sliding');
		$view = new Zend_View();
		$paginator->setView($view);

		//this are your results from db        
		$this->view->productbyCategory = $paginator;
		//var_dump($paginator);
		  echo count($paginator);
		//this is paginator
		$this->view->paginator = $paginator;
		*/
		
		
		$this->view->productbyCategory = $productbyCategory;		
	     $modelSuplier=new Model_Supplier();
		 $splier=$modelSuplier->getSupplierById($pviews[0]['s_id']);
		 $this->view->spname=$splier[0]['s_ten'];
	     
		
	}
	public function getproducthotAction(){
	          
	    $productFinder = new Model_Product();
        $this->view->products = $productFinder->getProductbyHot();
	}
	public function tryzendpaginatorAction()
	{    
	
	    $productFinder = new Model_Product();
         $resultdb= $productFinder->tryzenpaginator();
	
		$pageNumber = 4 ; //or whatever you wish
		$itemNumber = 2; //or whatever you wish
		$paginator = Zend_Paginator::factory($resultdb);
		
		$paginator->setItemCountPerPage($itemNumber);
		$paginator->getItemsByPage($pageNumber);
		$paginator->setCurrentPageNumber($this->_getParam('page'));
		Zend_Paginator::setDefaultScrollingStyle('Sliding');
		$view = new Zend_View();
		$paginator->setView($view);

		//this are your results from db        
		$this->view->productFinder = $paginator;
      
		//this is paginator
		$this->view->paginator = $paginator;
	
	}
     public function viewbyparentAction()
	 {
	 
	 $id = (int)$this->getRequest()->getParam('cat_id');
	 
	 $categoryModel = new Model_Category();
	 $results = $categoryModel->getCategoryByParentId($id );
	 var_dump($results);
	 $this->view->results=$results;
	 
	 
	 
	 
	 
	 
	 }

}